﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Threading;

namespace FCS.Communication
{
    /// <summary>
    /// This class contains helper methods that allow the system to contact the outside world via email
    /// </summary>
    public class EmailModule
    {
        /// <summary>
        /// Sends an email to maquina-status@engr.wisc.edu
        /// </summary>
        /// <param name="subject">Subject of email</param>
        /// <param name="message">Message body of email</param>
        public static void SendStatusEmail(string subject, string message)
        {
            // Run this on another thread
            new Thread(() =>
            {
                SmtpClient _client = new SmtpClient("mx1.cae.wisc.edu");
                MailMessage email = new MailMessage();

                email.From = new MailAddress("server@enlight-server.engr.wisc.edu", "Enlight Fountain Server");
                email.IsBodyHtml = false;
                email.Subject = subject;
                email.To.Add("maquina-status@engr.wisc.edu");
                email.Body = message;
                _client.Send(email);
            }).Start();
        }
    }
}
